<div>
	<div>
		<label>Thời gian làm bài còn : </label>
        <div class="counting">
            <div id="counter"></div>
            <div class="desc">
                <div>Giờ</div>
                <div>Phút</div>
                <div>Giây</div>
            </div>
        </div>
	</div>
</div>

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'exam-form',
    'htmlOptions' => array('enctype'=>'multipart/form-data')
)); ?>
<div class="exam">
	<?php if ($question) { ?>
	<ul>
		<?php foreach ($question as $index => $value) { ?>
		<li class="question">
			<p class="no">Câu <?php echo ($index + 1)  . " : "?></p>
			<p class="title"><?php echo $value->title ?></p>
			
			<?php if ($value->type == Question::ISingle) { ?>
			<ul class="answer">
			<?php foreach ($value->getExamAnswer() as $key => $ans) {?>
				<li>
					<input type="hidden" name="exam[<?php echo $value->id ?>][answer][id][]" value="<?php echo $ans->id ?>" />
					
					<input class="check" type="radio" id="<?php echo $index.$key ?>" name="exam[<?php echo $value->id ?>][answer][check]" value="<?php echo $ans->id ?>" />
					<p class="title">
						<label for="<?php echo $index.$key ?>"><?php echo $ans->title ?></label>
					</p>
				</li>
			<?php }?>
			</ul>
			<?php }elseif ($value->type == Question::IText) { ?>
                <?php echo CHtml::activeFileField($exam_upload, 'file'); ?>
			    <textarea class="text" rows="3" cols="4" name="exam[<?php echo $value->id ?>][answer][text]"></textarea>
			<?php }?>
		</li>
		<?php }?>
	</ul>
	<?php } ?>
</div>
<div>
	<input type="submit" value="Nộp bài" id="send_exam">
</div>
<?php $this->endWidget(); ?>
<script type="text/javascript">
    $(function(){
        $('#exam-form').submit(function(){
            $("#send_exam").remove();
        });

        $('#counter').countdown({
            image: '<?php echo Yii::app()->theme->baseUrl ?>/resource/images/digits.png',
            startTime: '<?php echo $time_str ?>',
            timerEnd: function(){ $('#send_exam').click(); },
            format: 'hh:mm:ss'
        });
    });
</script>